﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FortuneHeaven.Web.Common;
using FortuneHeavenBAL;
using FortuneHeavenCommon.Enum;
using FortuneHeavenCommon.DataMap;

namespace FortuneHeaven.Web.Pages.UserCenter
{
    public partial class SpreadList : CheckAuthPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            SetPageHeader(FortuneHeavenCommon.Enum.MainPageTabType.hidden);
            this.usPager.PagerChanged += new Web.Controls.TextPagination.PagerChangeHandler(usPager_PagerChanged);
            if (!IsPostBack)
            {
                ltName.Text = AuthorityCenter.CurrentUserName;
                this.ltUserName.Text = AuthorityCenter.CurrentUserName;
                UserInforBO bo = new UserInforBO();
                UserInfor user = bo.GetUserInfor(AuthorityCenter.CurrentUserID);
                if (user != null)
                {
                    ltSpreadValue.Text = user.SpreadValue.ToString();
                }
                ResetList();
            }
        }

        void usPager_PagerChanged(object sender, int currentpage)
        {
            UserSpreadBO gift = new UserSpreadBO();
            this.rpSpread.DataSource = gift.GetUserSpreads(this.usPager.CurrentPageIndex, this.usPager.PageSize, (int)SpreadType.charge, AuthorityCenter.CurrentUserID);
            rpSpread.DataBind();
        }

        public void ResetList()
        {
            UserSpreadBO gift = new UserSpreadBO();
            this.usPager.RecordCount = gift.GetTotalSize((int)SpreadType.charge, AuthorityCenter.CurrentUserID);
            this.usPager.CurrentPageIndex = 1;
        }
    }
}